﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YRevitJig
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class PickPoint : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			try
			{
				UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
				ViewAssist.ViewValidating(activeUIDocument.Document, activeUIDocument.ActiveView);
				XYZ xyz = activeUIDocument.Selection.PickPoint("请选择第一点：");
				XYZ xyz2 = activeUIDocument.Selection.PickPoint(xyz, activeUIDocument, "请选择第二点：");
				Transaction transaction = new Transaction(activeUIDocument.Document);
				transaction.Start("CreateCurve");
				Line line = Line.CreateBound(xyz, xyz2);
				activeUIDocument.Document.Create.NewDetailCurve(activeUIDocument.ActiveView, line);
				transaction.Commit();
			}
			catch
			{
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
